/*
@Time : 2020/8/6 10:33
@Author : lym
@File : UserService
@Software: GoLand
*/
package service

import (
	"gin-YiStudio-V1/dao/model"
	"github.com/astaxie/beego/logs"
	"github.com/jinzhu/gorm"
)

type UserServiceImpl struct {
	User *model.User
}

type UserService interface {
	/**
	判断手机号是否存在
	*/
	IsTelephoneExist(db *gorm.DB, telephone string) bool
}

/**
 * @Author lym
 * @Description 判断电话号是否存在
 * @Date 2020-08-6, 星期四 10:08
 * @Param db gorm.DB指针
 * @Param telephone 电话
 * @return
 **/
func (u *UserServiceImpl) IsTelephoneExist(db *gorm.DB, telephone string) bool {
	var user model.User
	db.Where("telephone = ?", telephone).First(&user)
	if user.ID != 0 {
		u.User = &user
		logs.Info("用户存在,telephone={%s},name={%s}", telephone, u.User.UserName)
		return true
	}
	return false
}
